package com.psp.bu.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.northend.util.NumUtil;
import com.psp.bu.controller.res.BaseResult;
import com.psp.bu.controller.res.ListResult;
import com.psp.bu.controller.res.bean.RBillListBean;
import com.psp.bu.controller.springmvc.req.GetBillExportParam;
import com.psp.bu.controller.springmvc.req.GetBillListParam;
import com.psp.bu.service.BillService;
import com.psp.bu.service.impl.PageResult;

@Component
public class BillController {

	@Autowired
	BillService billServiceImpl;

	/**
	 * 导出资金账单
	 * 
	 * @param param
	 * @param request
	 * @param response
	 * @return 
	 */
	public BaseResult export(GetBillExportParam param, HttpServletRequest request, HttpServletResponse response) {

		String uid = "";
		Integer type = param.getType();

		billServiceImpl.export(uid, type);
		return null;
	}

	/**
	 * 得到资金列表
	 * 
	 * @param param
	 * @param request
	 * @param response
	 * @return
	 */
	public ListResult<RBillListBean> list(GetBillListParam param, HttpServletRequest request,
			HttpServletResponse response) {
		ListResult<RBillListBean> result = new ListResult<>();
		int page = NumUtil.toInt(param.getPage(), 0);
		int pageSize = 10;
		String uid = "";
		int type = NumUtil.toInt(param.getType(), 0);

		PageResult<RBillListBean> resList = billServiceImpl.getList(page, pageSize, uid, type);

		result.setData(resList.getData());
		result.setPage(page);
		result.setTotalSize(resList.getCount());
		result.setToken(param.getToken());

		return result;
	}

}
